﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NutriLeaf.Web.Core.Recipe
{
    public class RecipieCook:IRecipeCook
    {
        public void CookRecipe(int userId, int recipeId, ref Model.NutriLeafDBEntities context)
        {
            Model.RecipeCook cook = new Model.RecipeCook();
            cook.UserID = userId;
            cook.RecipeID = recipeId;
            context.RecipeCooks.AddObject(cook);
            context.SaveChanges();
        }

        public void RemoveRecentCook(int userId, ref Model.NutriLeafDBEntities context)
        {
            context.DeleteObject(context.RecipeCooks.Where(p => p.UserID == userId).First());
            context.SaveChanges();
        }

        public void RemoveCook(int recipeCookId, ref Model.NutriLeafDBEntities context)
        {
            context.DeleteObject(context.RecipeCooks.Where(p => p.RecipeCookID == recipeCookId).First());
            context.SaveChanges();
        }

        public List<Model.Recipe> GetRecipeMostCooked(int userId, ref Model.NutriLeafDBEntities context)
        {
            ///will implelment later
            throw new NotImplementedException();
        }
    }
}